<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="/thinkphp/Public/js/jquery-1.11.3.js"></script>
    <script>
        $(function(){
//            $.ajax()
            $("#username").blur(function(){
                var v = $(this).val();
                if (v.length>3){
                    $("#msg").html('');
                    var url = '/tp/Home/Index/checkUserAjax';
                    var sData = {
                        name:v
                    };
                    $.ajax(url,{
                        data:sData,
                        dataType:'json',
                        success:function(d){
                            console.log(d);
                            if (d.status == 1){
                                $("#msg").html(d.msg);
                                $("#btn").attr('disabled',false);
                            } else {
                                $("#msg").html(d.msg);
                                $("#btn").attr('disabled',true);
                            }
                        }
                    })
                } else {
                    $("#msg").html('用户名必须大于6个字符');
                }
            })
        });
    </script>
</head>
<body>
<h2>用户注册</h2>
<form action="/thinkphp/Home/Index/register" method="post">
    <table>
        <tr>
            <td>用户名</td>
            <td><input type="text" name="username" id="username" placeholder="用户名不得低于6个字段"></td>
            <td id="msg"></td>
        </tr>

        <tr>
            <td>密码</td>
            <td><input type="password" name="password"></td>
        </tr>
        <tr>
            <td>确认密码</td>
            <td><input type="password" name="password2"></td>
        </tr>
        <tr>
            <td>email</td>
            <td><input type="text" name="email"></td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><input type="submit" value="注册" id="btn"></td>
        </tr>
    </table>
</form>
</body>
</html>